﻿using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;

namespace kb_24_the_game
{
    internal class TextLader
    {
        #region variabele

        private StreamReader reader;
        private List<string> regels;
        private string regel, level;
        private string oudeWaarde;
        private int regelNummer = -1;
        private static string directory = "Content/Tekstbestanden/";

        #endregion variabele

        public string VolgendeRegel(string level)
        {
            if (oudeWaarde != level)
            {
                this.level = level;
                LeesRegelsIn();
                regelNummer = -1;
                oudeWaarde = level;
            }
            else
            {
                oudeWaarde = level;
            }

            regelNummer++;
            try
            {
                return regels[regelNummer];
            }
            catch
            {
                return "##";
            }
        }

        private void LeesRegelsIn()
        {
            reader = new StreamReader((directory + level));
            regels = new List<string>();
            while ((regel = reader.ReadLine()) != null)
            {
                regels.Add(regel);
            }
            reader.Dispose();
        }

        public Vector2 Position()
        {
            if (level == "level1.txt")
            {
                return new Vector2(20, 520);
            }
            if (level == "level2.txt")
            {
                return new Vector2(20, 520);
            }
            if (level == "level3.txt")
            {
                return new Vector2(20, 520);
            }
            if (level == "level4.txt")
            {
                return new Vector2(20, 520);
            }
            if (level == "level5.txt")
            {
                return new Vector2(20, 520);
            }
            else return new Vector2(0, 0);
        }
    }
}